package helper.request.logandreg;

import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;

import server.dbconnector.DatabaseConnector;
import base.*;
import helper.request.RequestAfterLogin;

public class LogRequest implements RequestAfterLogin{
	private static final long serialVersionUID = 1581384545193556446L;
	private User currentuser;
	private ArrayList<Log> logList;
	public LogRequest(User currentuser,ArrayList<Log> logList){
		this.currentuser=currentuser;
		this.logList=logList;
	}
	
	@Override
	public boolean execute() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public User getcurrentuser() {
		return currentuser;
	}

	@Override
	public int getcurrentuserid() {
		return currentuser.getid();
	}
	@Override
	public void process(DatabaseConnector dc) throws SQLException{
		for(int i=0;i<logList.size();i++)
		dc.commit("insert into log(userID,description,datetime) values("+currentuser.getid()+",'"+logList.get(i).toString()+"','"+DateFormat.getDateInstance().format(logList.get(i).getDate())+"')"); 
	}

}

